package com.unidt.www.module.system.controller.admin.organ;

import com.unidt.www.framework.common.pojo.CommonResult;
import com.unidt.www.module.system.service.organ.IOrganCodeService;
import com.unidt.www.module.system.service.organ.dto.OrganCodeDto;
import com.unidt.www.module.system.service.organ.dto.OrganCodeTreeDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static com.unidt.www.framework.common.pojo.CommonResult.success;

/**
 * @Author sk
 * @Description:
 * @Date 2022/12/8 16:56
 **/
@Api(tags = "管理后台 - 区域查询")
@RestController
@RequestMapping("/system/organ")
@Slf4j
public class OrganController {

    @Resource
    IOrganCodeService organCodeService;


    @PostMapping("/getById/{organId}")
    @ApiOperation("获取区域信息")
    public CommonResult<OrganCodeDto> getById(@PathVariable(value = "organId") Long organId) {
        return success(organCodeService.getById(organId));
    }



    @PostMapping("/getChildren/{organId}")
    @ApiOperation("获取下级区域")
    public CommonResult<List<OrganCodeDto>> getChildren(@PathVariable(value = "organId") Long organId) {
        return success(organCodeService.getChildren(organId));
    }


    @PostMapping("/getTree/{organId}")
    @ApiOperation("获取区域树形结构")
    public CommonResult<List<OrganCodeTreeDto>> getTree(@PathVariable(value = "organId") Long organId) {
        return success(organCodeService.getTree(organId));
    }


}
